In this quick start you'll create a basic Visual Studio project that references Reports for WPF for previewing reports and documents.
To create a basic form for previewing reports and documents:
-
Create a new WPF application in Visual Studio.
-
Add a reference to the C1.WPF.C1Report assembly to your project:
-
Select the Add Reference option from the Project menu of your project.
-
Select the ComponentOne WPFReport assembly from the list on the .NET tab, or on the Browse tab, browse to find the C1.WPF.C1Report.dll file and click OK.
-
Double-click the window caption area to open the Code view. At the top of the file, add the following Imports statement (using in C#):
Imports C1.C1Preview
This makes the objects defined in the Reports for WPF assembly visible to the project.
-
From the View menu, select Designer to return to Design view.
-
From the Toolbox, double-click the standard DocumentViewer and Button controls to add them to your window. Then resize the window and the control to fill the window.
-
Select the button control and from the Properties window set the Button.Content property to "View document".
-
Double-click the Button control to open the Code view, and add the following code to the Button_Click handler:
Visual Basic |
Copy Code
|
Dim doc As New C1.C1Preview.C1PrintDocument()
doc.Body.Children.Add(New RenderText("Hello World!"))
DocumentViewer1.Document = doc.FixedDocumentSequence
|
C# |
Copy Code
|
C1.C1Preview.C1PrintDocument doc = new C1.C1Preview.C1PrintDocument();
doc.Body.Children.Add(new RenderText("Hello World!"));
documentViewer1.Document = doc.FixedDocumentSequence;
|
-
Run the application and click the View document button. The report will take a few seconds to load, and should look similar to the following:
See Also